//
//  vdTexNode.h
//  Void Dead
//
//  Created by Sidney Just on 17.11.09.
//
//  Copyright © 2009 by Sidney Just
//  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
//  documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
//  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
//  and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
//  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
//  PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
//  FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
//  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#import <Foundation/Foundation.h>

#import "vdHeader.h"

/**
 * This Class represents an empty texture, the loading function must be done in a subclass.
 * <br>You can create your own texture loading function by subclassing this class. The [vdTexNode loadTexture] function will be called automatically.
 **/
@interface vdTexNode : NSObject {
	//\cond
	GLuint texture;
	GLfloat dimension_x;
	GLfloat dimension_y;
	NSString *name;
	//\endcond
}

/**
 * The handle to the texture
 **/
@property GLuint texture;

/**
 * The width of the texture in pixels
 **/
@property GLfloat dimension_x;

/**
 * The height of the texture in pixels
 **/
@property GLfloat dimension_y;

/**
 * The name of the texture (eg. "Test.png")
 **/
@property (nonatomic, retain) NSString *name;

/**
 * Returns the pointer to the texture handle
 @return Pointer to the texture handle
 **/
- (GLuint *)getTexture;

/**
 * This functions sets the name string and calls [vdTexNode loadTexture].
 @param file Name of the texture
 @return Pointer to the texture
 **/
- (id)initWithFile:(NSString *)file;

/**
 * Returns YES if the image dimension is power of two, otherwise NO
 @return YES if the image dimension is power of two, otherwise NO
 **/
+ (BOOL)isPowerOfTwo:(NSString *)image;

/**
 * Creates a new vdTexNode with the given texture handle and size.
 @param handle Handle to an OpenGL texture
 @param rect Size of the texture
 @return Pointer to an vdTexNode instance.
 @remark You need to destroy the texture handle by yourself via glDestroyTexture if you don't need the texture anymore. This function will only create a wrapper instance around the given texture handle
 **/
- (id)initWithHandle:(GLuint)handle andSize:(CGRect)rect;

@end
